<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
    <base href="<%=basePath%>">
    <meta charset="utf-8" />
    <title>添加催收记录</title>

    <%-- <link href="static/css/bootstrap.min.css" rel="stylesheet" />--%>
    <link href="static/mycss/bootstrap.min.css" rel="stylesheet" />
    <link href="static/sweetalert/sweetalert.css" rel="stylesheet" />
    <script src='static/js/jquery-1.9.1.min.js'></script>
    <script type="text/javascript" src="static/js/layer.js"></script>
    <link rel="stylesheet" href="static/css/layui.css" media="all">
    <script src='static/js/laydate/laydate.js'></script>
    <script src='static/sweetalert/sweetalert.min.js'></script>
    <style>
        .divcss5{width:200px;}
        .divcss6{width:120px;}
    </style>
    <script type="text/javascript">
        $(top.hangge());
        $(document).ready(function() {
            $("#radio1").attr("checked","checked")
            $("#mesMode option[value='"+0+"']").attr("selected",true);
          if($("#mesMode").val()==0){
             $("#mestext").val("您在XX上的借款已逾期，将影响征信记录。请务必于今日14点前还款，否则我司将联系您的亲属督促还款！(今日现金)")
          };
        });
        function changgeMessage(){
            if($("#mesMode").val()==0){
                $("#mestext").val("您在XX上的借款已逾期，将影响征信记录。请务必于今日14点前还款，否则我司将联系您的亲属督促还款！(今日现金)")
            };
            if($("#mesMode").val()==1){
                $("#mestext").val("由于您未及时偿还您在XX上的借款，我司决定明日早上九点后向您的父母透露您在XX的借款事实，请尽快还款！(今日现金)")
            };
            if($("#mesMode").val()==2){
                $("#mestext").val("您在XX的借款已逾期，由于多次联系您未果，我方将在24小时后通过您的亲友联系您，并在必要时透露您的借款事实请其督促您还款，特此知会。(今日现金)")
            };
            if($("#mesMode").val()==3){
                $("#mestext").val("您在XX的借款已逾期，请立即还款！鉴于您电话不接短信不回的情况，我司将拨打您重要联系人的电话请其督促您还款。(今日现金)")
            };
            if($("#mesMode").val()==4){
                $("#mestext").val("您在XX的借款已逾期，为修复您的征信，避免对您生活，工作及名誉带来影响，请于今日16点前偿还欠款！(今日现金)")
            };
            if($("#mesMode").val()==5){
                $("#mestext").val("您在XX的借款已逾期，为避免个人信用及芝麻信用受损，请于今天12点前处理逾期欠款，若已还款无需理会。(今日现金)")
            };
            if($("#mesMode").val()==6){
                $("#mestext").val("xx在XX的借款已逾期多日，多次联系无果！因您作为其紧急联系人，烦请通知其立即还款。(今日现金)")
            };
            if($("#mesMode").val()==7){
                $("#mestext").val("您在XX的借款已严重逾期，因您屡次爽约不履行还款义务，我司将与您公司，亲人，好友联系请其督促您还款并当面向您催收，请立即还款。(今日现金)")
            };
            if($("#mesMode").val()==8){
                $("#mestext").val("请立即结束拒接XX电话的错误做法并与我司沟通解决问题，避免增加罚息并损害信用记录，请立即偿还欠款，否则我司将联系您的亲友请其督促您还款。(今日现金)")
            };
            if($("#mesMode").val()==9){
                $("#mestext").val("请如约偿还XX逾期欠款，否则，我司将联系您的亲属以及您手机通讯录内近一个月所有联系人请其督促您还款。(今日现金)")
            };
            if($("#mesMode").val()==10){
                $("#mestext").val("由于您拒绝偿还在XX的借款，我司将于明日下午16点后向您的亲属及通讯录朋友圈逐一告知您定的欠款事实并请求其督促您还款，请立即还款。(今日现金)")
            };
        }
        function tijiao() {
             var isTijiao = true;
             var val = $('input:radio[name="sendmode"]:checked').val();
            console.log(val)
            sweetAlert("短信功能禁用!");
            return;
            if (val == 1) {
                var sendtime = $("#sentime").val();
                if (sendtime == null || sendtime == "") {
                    sweetAlert("时间不能为空!");
                    //alert("时间不能为空")
                    isTijiao = false;
                }else{
                    var reg=new RegExp(/\d{4}-\d\d-\d\d \d\d:\d\d/);
                    if(!reg.test(sendtime)){
                        sweetAlert("时间输入不对!");
                       // alert("时间输入不对")
                        isTijiao = false;
                    }else{
                        var strTime =sendtime+ ":"+"00"
                        var date = new Date(strTime);
                        var nowDate = new Date();
                        if(date<=nowDate){
                            isTijiao = false;
                            sweetAlert("不能小于当前时间!");
                           // alert("不能小于当前时间")
                        }
                    }
                }

            }
            var messageText =  $("#mestext").val();
            messageText = $.trim(messageText)
            console.log("text")
            console.log(messageText)
            if (messageText == null || messageText == "") {
                isTijiao = false;
                sweetAlert("短信内容不能为空!");
                //alert("短信内容不能为空")
            }
            console.log(isTijiao)
            if (isTijiao == true) {
            $.ajax({
                type: "POST",
                dataType: "json",
                url: "cuijimanage/doMessage.do",
                data: $("#messageForm").serialize(),
                success: function (data) {
                    if(data.num==1){
                        //alert("提交成功")
                        $("#save").attr("disabled","disabled");
                        layer.alert('提交成功', {
                                    skin: 'layui-layer-molv' //样式类名
                                    ,closeBtn: 0
                                },
                                function(){
                                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                    parent.layer.close(index); //再执行关闭
                                })
                    }else if(data.num==0){
                          swal({   title: "发送失败",
                            text: "是否关闭",
                            type: "warning",
                            showCancelButton: true,
                            confirmButtonColor: "#DD6B55",
                            confirmButtonText: "关闭窗口!",
                            closeOnConfirm: true },
                            function(){
                                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                parent.layer.close(index); //再执行关闭
                            });
                       //alert("发送失败");
                    }
                    console.log("返回值data：" + data.num);
                },
            });
        }
        }
    </script>
    <style>
        .divcss5{width:150px;height:30px;} 
    </style>
</head>
<body>
<div class="col-sm-12">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <form  id="messageForm" name="signUpForm" class="form-horizontal m-t" id="commentForm" novalidate="novalidate">
                <input type="hidden" name="contType" value = "${contactsInfoMap.contType}">
                <input type="hidden" name="contUserName" value = "${contactsInfoMap.contUserName}">
                <input type="hidden" name="tellPhone" value = "${contactsInfoMap.tellPhoneShow}">
                <input type="hidden" name="callLoanNid" value = "${contactsInfoMap.callLoanNid}">
                <input type="hidden" name="callUser" value = "${contactsInfoMap.callUser}">
                <input type="hidden" name="realName" value = "${contactsInfoMap.realName}">
                <br>
                <div class="form-group col-sm-12">
                    <label class="col-sm-4 control-label divcss6"> 催收对象:</label>
                    <div class="col-sm-8" style="display: inline-block;color:grey">
                        <label class="control-label">
                            ${contactsInfoMap.realName}
                        </label>
                    </div>
                </div>
                <div class="form-group col-sm-12">
                    <label class="col-sm-4 control-label divcss6"> 发送对象:</label>
                    <div class="col-sm-8" style="display: inline-block;color:grey">
                        <label class="control-label">
                            ${contactsInfoMap.contUserName}
                        </label>
                    </div>
                </div>
                <div class="form-group col-sm-12">
                    <label class="col-sm-4 control-label divcss6"> 关系:</label>
                    <div class="col-sm-8" style="color:grey; display: inline-block">
                        <label class="control-label">
                            <c:forEach  var="callship" varStatus="var" items="${linkManShipMap}">
                                <c:if test="${callship.key eq contactsInfoMap.contShip}">
                                    ${callship.value}
                                </c:if>
                            </c:forEach>
                        </label>
                    </div>
                </div>
                <div class="form-group col-sm-12">
                    <label class="col-sm-4 control-label divcss6">联系人手机号:</label>
                    <div class="col-sm-8"  style="display: inline-block;color:grey">
                        <label class="control-label">  ${contactsInfoMap.tellPhone}</label>
                    </div>
                </div>
                <div class="form-group col-sm-12">
                    <label class="col-sm-4 control-label divcss6">短信模板:</label>
                    <div class="col-sm-8" style="display: inline-block">
                        <select  name = "mode" id = "mesMode"    class="form-control" onchange="changgeMessage()" style="font-size: 15px;padding: 2px 3px;color: #000;width: 300px;">
                            <option value="0">s1联系有关系亲属</option>
                            <option value="1">s1联系父母</option>
                            <option value="2">s1联系亲友</option>
                            <option value="3">s1联系亲密的人</option>
                            <option value="4">S1风控部提示</option>
                            <option value="5">S1芝麻信用</option>
                            <option value="6">S2亲友</option>
                            <option value="7">S2当面催收</option>
                            <option value="8">S2结束错误做法</option>
                            <option value="9">S2如约处理欠款</option>
                            <option value="10">S2通报亲属</option>
                        </select>
                    </div>
                </div>
                <div class="form-group col-sm-12">
                    <label class="col-sm-4 control-label divcss6" style="top: -40px";>短信内容:</label>
                    <div class="col-sm-8" style="display: inline-block">
                                     <textarea id="mestext" name = "message" rows="3" style="width:300px"  class="form-control">
                                        </textarea>
                    </div>
                </div>
                <div class="form-group col-sm-12">
                    <label class="col-sm-4 control-label divcss6">发送时间:</label>
                    <div class="col-sm-8" style="display: inline-block">
                        <input type="radio" id="radio0" name="sendmode" value = "1">指定时间:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <%--<input type="time" id="sentime" name = "sendTime" class="divcss5">--%>
                        <input id="sentime" name = "sendTime" class="laydate-icon"  onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm'})">
                        <br><br>
                        <input type="radio" id="radio1"  name="sendmode" value = "0"> 即时发送
                    </div>
                </div>
                <div class="form-group col-sm-12">
                    <div align="center" class="col-sm-7" >
                        <input type="button" id = "save" value="确认发送" onclick="tijiao()" class="btn btn-primary" />
                    </div>
                </div>






            </form>
        </div>
    </div>
</div>
</body>
</html>
